#include <iostream>
#include <pthread.h>
#include <signal.h>
#include <unistd.h>
#include <fcntl.h>
using namespace std; 


void* handle(void* v){
	cout << " I am in thread" << endl; 
	sigset_t mask; 
	int sig; 
	sigaddset(&mask,SIGUSR1);
	int r = sigwait(&mask,&sig); 
	if(r != 0){
		cout << "error" << endl; 
		pthread_exit(NULL); 
	}
	if(sig == 10){
		cout << "sigusr came from kill " << endl;
	}
	cout << "  I am out of thread" << endl;
}

int main(){
	pthread_t t; 
	cout << " my pid is : " << getpid() << endl; 
	sigset_t mask; 
	sigfillset(&mask); 
	pthread_sigmask(SIG_BLOCK,&mask,0); 
	pthread_create(&t,NULL,handle,NULL); 
	while(1){
		sleep(1); 
		cout << " hello" << endl;
	}

}
